package com.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.bean.LogBean;
import com.project.mapper.ILogMapper;
import com.project.mapper.IRoleMapper;
import com.project.service.ILogService;
import com.project.service.IPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;

@Service
@Transactional
public class LogServiceImpl implements ILogService {
    @Autowired
    private ILogMapper mapper;

    @Override
    public IPage<LogBean> findByItem(Integer pageNO, LocalDate startDate, LocalDate endDate) {
        QueryWrapper<LogBean> queryWrapper=new QueryWrapper<>();
        if (startDate!=null){
            queryWrapper.ge("l_createDate", startDate);
        }
        if (endDate!=null){
            queryWrapper.le("l_createDate", endDate);
        }
        return mapper.selectPage(new Page<>(pageNO,3),queryWrapper);
    }

    @Override
    public void add(LogBean log) {
        mapper.insert(log);
    }
}
